$(function(){
	$("#file_upload").uploadify({
		buttonText:'上传文件',
		auto:true,
		progressData:'speed',
		multi:false,
		height:20,
		width:55,
		overrideEvents:['onDialogClose'],
		fileTypeDesc:'文件格式:',
		queueID:'instructionfile',
		fileTypeExts:'*.xlsx;',
		fileSizeLimit:'15MB',
		swf:'plug-in/uploadify/uploadify.swf',	
		uploader:'uploadCinemaController.do?importExcel',
		onUploadStart : function(file) { 
			var documentTitle = $('#documentTitle').val();
			$("#msg").html("正在导入.......");
			$('#file_upload').uploadify("settings", 
					"formData", 
					{'documentTitle':documentTitle});$('#file_upload').fadeOut();
		},
		onUploadSuccess : function(file, responseData, response) {
			var data = $.parseJSON(responseData);
			if(data.success){
				$.ajax({
					url : "uploadCinemaController.do?checkExcel",
					data : {
						"filePath" : data.obj
						},
					cache : false,
					dataType : 'json',
					type : 'POST',
					success : function(data2){
						if(data2.success){
							$.ajax({
								url : "uploadCinemaController.do?readExcel",
								data : {
									"filePath" : data2.obj
									},
								cache : false,
								async : false,
								dataType : 'json',
								type : 'POST'
							});
							top.window.tip(data2.msg);
							frameElement.api.reload(win,"zyCinemaController.do?zyCinema");
							frameElement.api.close();
						}else{
							$("#file_upload").fadeIn();
							$("#msg").html("");
							tip(data2.msg);
						}
					}
				});
			}else{
				tip(data.msg);
			}
		},onFallback : function(){
			tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试");
		},onSelectError : function(file, errorCode, errorMsg){
			switch(errorCode) {
				case -100:
					tip("上传的文件数量已经超出系统限制的"+$('#instruction').uploadify('settings','queueSizeLimit')+"个文件！");
					break;
				case -110:
					tip("文件 ["+file.name+"] 大小超出系统限制的"+$('#instruction').uploadify('settings','fileSizeLimit')+"大小！");
					break;
				case -120:
					tip("文件 ["+file.name+"] 大小异常！");
					break;
				case -130:
					tip("文件 ["+file.name+"] 类型不正确！");
					break;
				}
		},onUploadProgress : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {}
	});
});